package com.erju.service.impl;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.erju.dao.SlLabMapper;
import com.erju.pojo.SlLab;
import com.erju.pojo.SlLabAppointment;
import com.erju.pojo.VO.AppointmentDetailVo;
import com.erju.service.SlLabService;
import com.erju.utils.PageHrlperUtils;
import com.erju.utils.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @Description: 实验室信息
 * @author: 86132
 * @date: 2022.03.21
 */
@Service
public class SlLabServiceImpl implements SlLabService {
    private static final Logger log = LoggerFactory.getLogger(SlLabServiceImpl.class);
    @Autowired
    SlLabMapper slLabMapper;


    @Override
    public Result<?> selectAll() {
        List<SlLab> sl_labs = slLabMapper.selectAll();
        return Result.success("成功", sl_labs);
    }


    @Override
    public Result<?> selectLabBySite() {
        SlLab sl_lab = slLabMapper.selectLabBySite();
        return Result.success("成功", sl_lab);
    }

    @Override
    public Result<?> selectLab(SlLab slLab) {
        slLab.setLab_site(slLab.getLab_site() == null ? "" : slLab.getLab_site());
        slLab.setLab_type(slLab.getLab_type() == null ? "" : slLab.getLab_type());
        slLab.setUse_flag(slLab.getUse_flag() == null ? "" : slLab.getUse_flag());
        List<SlLab> slLabs = slLabMapper.selectLab(slLab);

        return PageHrlperUtils.PageResult(slLabs, "查询实验室列表");
    }

    @Override
    public Result<?> deleteLab(SlLab slLab) {
        Boolean flag = slLabMapper.deleteLab(slLab);
        return Result.success("成功", flag);
    }

    @Override
    public Result<?> addLab(SlLab slLab) {
        Boolean flag = slLabMapper.addLab(slLab);

        return Result.success("成功", flag);
    }

    @Override
    public Result<?> updateLab(SlLab slLab) {
        Boolean flag = slLabMapper.updateLab(slLab);
        return Result.success("成功", flag);
    }

    /***
     *id查询实验室信息
     * @Author erju
     * @Date 14:26 2022/3/24
     * @Param [id]
     * @return com.erju.utils.Result<?>
     **/
    @Override
    public Result<?> selectLabById(Integer id) {
        SlLab lab = slLabMapper.selectLabById(id);

        return Result.success("成功", lab);
    }


}
